#include "comm.h"

int main()
{
    int fd = open(FILE_NAME,O_WRONLY);
    if(fd < 0)
    {
        perror("open");
        return 1;
    }
    int fd2 = open("file.txt", O_RDONLY);
    if(fd2 < 0)
    {
        perror("open");
        return 2;
    }
    char buff[128];
    while(1)
    {
        buff[0] = '\0';
        ssize_t s = read(fd2,buff,sizeof(buff));
        if(s > 0)
        {
            write(fd,buff,s);
        }
        else if(s == 0)
        {
            printf("file end!\n");
            break;
        }
        else
        {
            printf("erro!\n");
            break;
        }
    }
    close(fd);
    close(fd2);

    return 0;
}